<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .fu{
            background-color: rgba(255,255,0,0.3);
            overflow:hidden;
            /*让父元素形成BFC结界，首尾子元素的外间距不会超过父元素的范围*/
        }
        .fu>div{
            width: 100px;
            height: 100px;
            background-color: rgba(0,0,255,0.6);
            border: 2px solid #00f;
            color: #fff;
        }
        .z1{
            margin-top: 50px;
            margin-bottom: 30px;
        }
        .z2{
            margin-top: 50px;
        }
        .z3{
            margin:0 auto;
            /*自动将本元素的左右外间距计算出来，居中显示*/
        }
        .z4{
            margin-bottom: 50px;
        }
        span{
            border: 1px solid red;
        }
        .s2{
            margin: 20px;
            /*span行内元素的垂直外间距不生效*/
        }
    </style>
</head>
<body>
<span>span1</span><span class="s2">span2</span><span>span3</span>
<div class="fu">
    <div class="z1">子元素1</div>
    <div class="z2">子元素2</div>
    <div class="z3">子元素3</div>
    <div class="z4">子元素4</div>
</div>
</body>
</html>